package com.sky.vo;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;

/**
 * 交易记录视图对象。
 * 向前端返回简化后的流水记录，包含方向、类别、金额等核心信息。
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class TransactionRecordVO {
    private Long id;
    private Long merchantId;
    private String direction; // INCOME/EXPENSE
    private String category; // ORDER/WITHDRAWAL/REFUND/ADJUSTMENT
    private BigDecimal amount;
    private String currency;
    private String occurredAt; // ISO string, e.g. 2025-10-19T12:34:56
    private Long orderId;
    private Long withdrawalId;
    private String description;
    // 新增：收入/支出详情（用于行展开展示）
    private IncomeDetailVO incomeDetail;
    private ExpenseDetailVO expenseDetail;

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class IncomeDetailVO {
        private String orderNo;
        private String studentName;
        private String merchantName;
        private String fileName;
        private BigDecimal unitPrice; // 由总金额/份数推导
        private Integer quantity; // 份数
        private BigDecimal totalAmount;
        private String completedAt; // ISO
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class ExpenseDetailVO {
        private String merchantName;
        private BigDecimal requestAmount;
        private BigDecimal shareRatio; // 0-1
        private String withdrawalTime; // 处理时间或申请时间（ISO）
        private BigDecimal payoutAmount; // 实际支出
    }
}